﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LotteryGen
{
    public partial class LotteryGen : Form
    {
        public LotteryGen()
        {
            InitializeComponent();
        }

        private void LotteryGen_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Convert UI input
            int Max = Int32.Parse(txtMax.Text), Min=Int32.Parse(txtMin.Text);
            int size = Max-Min+1;
            int [] balls = new int[size];
            //Queue<int> ballQueue = new Queue<int>();

            //Initialize balls
            for (int i = Min; i <= Max; i++) balls[i-Min] = i;

            //Swap
            Random rand = new Random();
            for (int i = 0; i < Int32.Parse(txtIteration.Text); i++)
            {
                int j = rand.Next(size);
                int k = rand.Next(size);
                int t = balls[j];
                balls[j] = balls[k];
                balls[k] = t;
            }
            
            //Render UI
            //ListViewItem lvi = new ListViewItem();
            //ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem();
            //lvsi.Text= "aa";
            //lvi.SubItems.Add(\
            lvResult.Items.Clear();
            int Special = Int32.Parse(txtSpecial.Text);
            int Amount = Int32.Parse(txtAmount.Text);
            for (int i = 0; i < Amount; i++)
            {
                if (i < Amount - Special)
                {
                    ListViewItem lvi  = lvResult.Items.Add("NORMAL");
                    lvi.SubItems.Add(balls[i].ToString());
                }
                else
                {
                    ListViewItem lvi  = lvResult.Items.Add("SPECIAL");
                    lvi.SubItems.Add(balls[i].ToString());

                }
                
            }
        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtAmount_TextChanged(object sender, EventArgs e)
        {

        }

        private void label7_Click_1(object sender, EventArgs e)
        {

        }
    }
}
